#ifndef __LASER_H
#define __LASER_H

#ifdef __cplusplus
extern "C"
{
#endif

#include "stm32f4xx_hal.h"
#include "karman.h"
#include "adc.h"
#include "utils.h"
#include "cmd.h"

/*Define Area*/
#define AVERAGE_AMOUNT 10

/* Trim Area */
#define useLaserLeft      1
#define useLaserRight     1
#define useLaserSideLeft  1
#define useLaserSideRight 1

/*Struct Area*/
  typedef struct
  {
    uint32_t adc_l;
    uint32_t adc_r;
    uint32_t adc_s;
  } LASER_ADC;
  typedef struct
  {
    uint32_t ADC_value[AVERAGE_AMOUNT];
    int ADC_final;
    float distance;
    float FAR_distance;
    float NEAR_distance;
    float FAR_voltage;
    float NEAR_voltage;
    float k_param;
    float b_param;
  } LASER;

/*Variable Area*/
  extern LASER laser_left;
  extern LASER laser_right;
  extern LASER laser_sideLeft;
  extern LASER laser_sideRight;

  extern LASER_ADC laser_adc[AVERAGE_AMOUNT];

  // extern PID_Struct laser_ypos_pid;
  // extern PID_Struct laser_xpos_pid;

/*Function Area*/
  // void laser_calculate_kb(LASER *sensor);
  // void laser_adc_split(LASER *laser_l, LASER *laser_r, LASER *laser_s);

  // float laser_calculate_distance(LASER *sensor, Kal_Struct *kal_laser_distance, Kal_Struct *kal_laser_adc);
  // float laser_calculate_x();
  // float laser_calculate_y();
  // float laser_calculate_angle();

  void laser_init();
  void laser_exe();
  void laser_print_distance();
  // void laser_print_pos();
  void laser_print_adc();

#if useLaserLeft
  float laser_left_distance();
#endif
#if useLaserRight
  float laser_right_distance();
#endif
#if useLaserSideLeft
  float laser_sideleft_distance();
#endif
#if useLaserSideRight
  float laser_sideright_distance();
#endif

#ifdef __cplusplus
}
#endif
#endif /*__LASER_H */